package shared.pojo

import upickle.default._

/** Created by yz on 7/11/2022
  */
object Pojo {

  val predict = Predict
  val user = User

  object Login {

    case class Request(name: String, password: String)

    object Request {

      implicit val rw = macroRW[Request]

    }

    case class Response(
        valid: Boolean,
        role: String = "",
        token: String = "",
        activated: Boolean = true,
        id: Int = 0,
        errorClass: String = "",
        email: String = ""
    )

    object Response {

      implicit val rw = macroRW[Response]

    }

  }
  object NewPassword {

    case class Request(name: String, newPassword: String)

    object Request {

      implicit val rw = macroRW[Request]

    }

  }

  object ConfirmActive {

    case class Response(hasActived: Boolean)

    object Response {

      implicit val rw = macroRW[Response]

    }

  }

  case class ValidData(valid: Boolean, message: String = "")

  object ValidData {
    implicit val rw = macroRW[ValidData]
  }

  case class UserNameData(name: String)

  object UserNameData {
    implicit val rw = macroRW[UserNameData]
  }

  case class EmailData(email: String)

  object EmailData {
    implicit val rw = macroRW[EmailData]
  }

  case class PhoneData(phone: String)

  object PhoneData {
    implicit val rw = macroRW[PhoneData]
  }

  case class RegisterUserData(
      name: String,
      fullName: String,
      password: String,
      unit: String,
      email: String,
      phone: String
  )

  object RegisterUserData {
    implicit val rw = macroRW[RegisterUserData]
  }

  case class UserData(
      name: String = "",
      password: String = "",
      remainTimes: String = "",
      startTime: String = "",
      endTime: String = "",
      fullName: String = "",
      unit: String = "",
      email: String = "",
      phone: String = ""
  )

  object UserData {
    implicit val rw = macroRW[UserData]
  }

  case class UserRowData(
      name: String = "",
      password: String = "",
      remainTimes: Option[Int] = None,
      startTime: Option[String] = None,
      endTime: Option[String] = None,
      fullName: String = "",
      unit: String = "",
      email: String = "",
      phone: String = ""
  )

  object UserRowData {
    implicit val rw = macroRW[UserRowData]
  }

  case class IdData(id: String = "")

  object IdData {
    implicit val rw = macroRW[IdData]
  }

  case class AdminData(account: String = "", email: String = "")

  object AdminData {
    implicit val rw = macroRW[AdminData]
  }

  object ChangePassword {

    case class Request(
        account: String = "",
        password: String,
        newPassword: String
    )

    object Request {

      implicit val rw = macroRW[Request]

    }

  }

  object ChangeEmail {

    case class Request(password: String, email: String)

    object Request {

      implicit val rw = macroRW[Request]

    }

  }

  case class ResultData(
      caseDouble: BigDecimal = 0,
      cirrhosis: BigDecimal = 0,
      lateFibrosis: BigDecimal = 0
  )

  object ResultData {
    implicit val rw = macroRW[ResultData]
  }

}
